$(function(){
    
    (function ($) {
        $.getUrlParam = function (name) {
            var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
            var r = window.location.search.substr(1).match(reg);
            if (r != null) return unescape(r[2]); return null;
        }
    })(jQuery);
    
    var tokenStr = $.getUrlParam('token'),
        copyBtn = $('.copy_btn'),
        iptBtn = $('.ipt'),
        center_div = $('.center_div');
  
    iptBtn.text(tokenStr);

    center_div.focus(function(){
        
        $("#left_hand").animate({
            left: "150",
            top: " -38"
        },{step: function(){
            if(parseInt($("#left_hand").css("left"))>140){
                $("#left_hand").attr("class","left_hand");
            }
        }}, 2000);
        $("#right_hand").animate({
            right: "-64",
            top: "-38px"
        },{step: function(){
            if(parseInt($("#right_hand").css("right"))> -70){
                $("#right_hand").attr("class","right_hand");
            }
        }}, 2000);  

    }).blur(function(){
        
        $("#left_hand").attr("class","initial_left_hand").attr("style","left:100px;top:-12px;");
        $("#right_hand").attr("class","initial_right_hand").attr("style","right:-112px;top:-12px");
        
    });
    

    var clipboard = new Clipboard('.copy_btn');
    
    clipboard.on('success', function(e) {
        
        $("#left_hand").animate({
            left: "150",
            top: " -38"
        },{step: function(){
            if(parseInt($("#left_hand").css("left"))>140){
                $("#left_hand").attr("class","left_hand");
            }
        }}, 2000);
        $("#right_hand").animate({
            right: "-64",
            top: "-38px"
        },{step: function(){
            if(parseInt($("#right_hand").css("right"))> -70){
                $("#right_hand").attr("class","right_hand");
            }
        }}, 2000);  
        
        copyBtn.text("already-copy");
        
        setTimeout(function () { 
            
            $("#left_hand").attr("class","initial_left_hand").attr("style","left:100px;top:-12px;");
            $("#right_hand").attr("class","initial_right_hand").attr("style","right:-112px;top:-12px");
            
            copyBtn.text("copy-token");
            
        }, 2500);
            
            


        
        //alert("copy成功");
    });
    
    
   
    
});